<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
async_test((t) => {
  let xmlWindow;

  t.add_cleanup(() => { xmlWindow.close(); });

  function checkWhitespaces() {
    var sourcePretty = xmlWindow.document.getElementsByClassName('pretty-print')[0];

    if (!sourcePretty || !sourcePretty.innerText) {
      requestAnimationFrame(t.step_func(checkWhitespaces));
      return;
    }

    assert_true(sourcePretty.innerText.includes(' bar '));

    t.done();
  }

  window.addEventListener("load", (e) => {
    xmlWindow = window.open('resources/leading-and-trailing-whitespaces.xml',
                            'XMLViewerTestWindow');
    xmlWindow.onload = t.step_func(checkWhitespaces);
  });
}, 'XMLTreeConverted');
</script>
</head>
<body>
</body>
</html>
